package com.ruoyi.third.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.validation.annotation.Validated;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.third.domain.ThirdConfigValue;
import com.ruoyi.third.service.IThirdConfigValueService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 配置值Controller
 * 
 * @author yepanpan
 * @date 2025-02-06
 */
@RestController
@RequestMapping("/third/configValue")
public class ThirdConfigValueController extends BaseController
{
    @Autowired
    private IThirdConfigValueService thirdConfigValueService;

    /**
     * 查询配置值列表
     */
    @PreAuthorize("@ss.hasPermi('third:configValue:list')")
    @GetMapping("/list")
    public TableDataInfo list(ThirdConfigValue thirdConfigValue)
    {
        startPage();
        List<ThirdConfigValue> list = thirdConfigValueService.selectThirdConfigValueList(thirdConfigValue);
        return getDataTable(list);
    }

    /**
     * 导出配置值列表
     */
    @PreAuthorize("@ss.hasPermi('third:configValue:export')")
    @Log(title = "配置值", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ThirdConfigValue thirdConfigValue)
    {
        List<ThirdConfigValue> list = thirdConfigValueService.selectThirdConfigValueList(thirdConfigValue);
        ExcelUtil<ThirdConfigValue> util = new ExcelUtil<ThirdConfigValue>(ThirdConfigValue.class);
        util.exportExcel(response, list, "配置值数据");
    }


    /**
     * 获取配置值详细信息
     */
    @PreAuthorize("@ss.hasPermi('third:configValue:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(thirdConfigValueService.selectThirdConfigValueById(id));
    }

    /**
     * 新增配置值
     */
    @PreAuthorize("@ss.hasPermi('third:configValue:add')")
    @Log(title = "配置值", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@Validated @RequestBody ThirdConfigValue thirdConfigValue)
    {
        return toAjax(thirdConfigValueService.insertThirdConfigValue(thirdConfigValue));
    }

    /**
     * 修改配置值
     */
    @PreAuthorize("@ss.hasPermi('third:configValue:edit')")
    @Log(title = "配置值", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@Validated @RequestBody ThirdConfigValue thirdConfigValue)
    {
        return toAjax(thirdConfigValueService.updateThirdConfigValue(thirdConfigValue));
    }

    /**
     * 删除配置值
     */
    @PreAuthorize("@ss.hasPermi('third:configValue:remove')")
    @Log(title = "配置值", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(thirdConfigValueService.deleteThirdConfigValueByIds(ids));
    }
}
